{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-left">
			<ul class="nav nav-tabs">
				<li>
					<a href="{:url('index')}">{$meta_title}</a>
				</li>
				<li  class="active">
					<a href="{:url('index_tree')}">树形版</a>
				</li>
			</ul>
		</div>
		{if session('user_auth.group')!=4&&session('user_auth.group')!=3}
		<div class="pull-right">
			<a href="{:url('add')}" class="btn btn-primary pull-right"> <i class="fa fa-plus-circle fa-lg"></i> 新增员工</a>
		</div>
		{/if}
	</header>
	<div class="main-box-body clearfix">
        <div class="row">
			<form method="get" action="{:url('index')}">
				<div class="col-sm-12 col-md-3">
					<input type="text" class="form-control" name="keyword" value="{$keyword|default=''}" placeholder="请输入关键字">
				</div>
				{if session('user_auth.group')!=4&&session('user_auth.group')!=3}
				<div class="col-sm-12 col-md-3">
					<select name="group" id="group" class="form-control">
						<option value="">请选择部门</option>
						{foreach name="grouplist" item="vo" key="k" }
							<option value="{$k}" {if $group==$k}selected {/if}>{$vo}</option>
						{/foreach}
					</select>
				</div>
				{/if}
				<div class="col-sm-12 col-md-3">
					<button class="btn btn-primary" type="submit">搜索</button>
				</div>
			</form>
		</div>
    <div class="main-box-body clearfix">
        <form class="ids">
            <div class="table-responsive clearfix">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th class="row-selected">
                                <input class="checkbox check-all" type="checkbox">
                            </th>
                            <th>ID</th>
                            <th>员工姓名</th>
                            <th>上级</th>
                            <th>授权岗位</th>
                            <th>操作</th>
                        </tr>
                    </thead>

                    <tbody>
                    {notempty name="list"}
                        {volist name="list" id="item"}
                            <tr>
                                <td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item.id}"></td>
                                <td>{$item.id}</td>
                                <td>
                                    {$item['level_show']}
                                    <a href="#" class="editable editable-click" data-id="{$item['id']}" data-name="title" data-type="text" data-pk="{$item['id']}" data-url="{:url('editable')}">{$item['title']}</a>
                                    <a class="add-sub-cate" title="添加子分类" href="{:url('add?pid='.$item['id'])}">
                                        <i class="fa fa-plus-square"></i>
                                    </a>
                                </td>
                                <td>{$members[$item['pid']]|default='超级管理员'}</td>
                                <td>{$grouplist[$item['group']]}</td>
                            
                                
                                <td>
                                    <a title="编辑" href="{:url('edit?id='.$item['id'])}">编辑</a>
                                    <a class="openDilog" href="javascript:;" url="{:url('User/authWindow',array('id'=>$item['uid']))}" class="table-link"><i class="fa fa-male"></i> 授权 
                                    <a class="confirm ajax-get" title="删除" href="{:url('del?id='.$item['id'])}">删除</a>
                                </td>
                            </tr>
                        {/volist}
                    {else/}
                        <td colspan="10" class="text-center"> aOh! 暂时还没有内容!</td>
                    {/notempty}
                    </tbody>
                </table>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function () {
    $.fn.editable.defaults.mode = 'popup';
    $.fn.editableform.buttons = '<button type="submit" class="btn btn-success editable-submit btn-mini"><i class="fa fa-check-square-o fa-white"></i></button>' +
    '<button type="button" class="btn editable-cancel btn-mini"><i class="fa fa-times"></i></button>';
    $('.editable').editable();
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
});
</script>
<script type="text/javascript" src="__PUBLIC__/plugs/layer/layer.js"></script>
<script type="text/javascript">
	$(function(){
		$('.openDilog').click(function(){
			layer.open({
				type: 2,
				title: false,
				area: ['90%', '80%'],
				content: $(this).attr('url')+"&_menu=hide&page=1"
			});
		});
	})
</script>
{/block}